export const mixinVideoSubtitle = {
  data() {
    return {
      mx_isShowSubtitle: false, //是否有字幕
      mx_isOpenSubtitleSetting: false, //打开字幕设置弹窗
      mx_isOpenSubtitle:1, //是否开启字幕 1开启 -1关闭
      mx_cueFontSize: 'medium', //字幕字体大小 large medium  small
    }
  },
  mounted() {
    this.mx_initSubtitleData();
  },
  methods: {
    mx_initSubtitleData() {
      this.mx_isAddVideoTrack = false;
      this.mx_isShowSubtitle = false;
      this.mx_isOpenSubtitleSetting = false;
      let font = localStorage.getItem('MP_FE_SUBTUTLE_FONT');
      this.mx_cueFontSize = font || 'medium';
      let isOpen = localStorage.getItem('MP_FE_IS_OPEN_SUBTUTLE');
      this.mx_isOpenSubtitle = isOpen || 1;
    },
    //关闭字幕弹窗
    mx_tapCloseOpenSubtitleSetting() {
      this.mx_isOpenSubtitleSetting = false;
    },
    //打开字幕设置弹窗
    mx_tapOpenSubtitleSetting() {
      this.mx_isOpenSubtitleSetting = true;
    },
    mx_tapSwitchSubtitleFont(curFont) {
      let removeClass = `video-cue-class-${this.mx_cueFontSize}`;
      this.mx_cueFontSize = curFont;
      if (!document.getElementById('videoCueBox')) {
        return;
      }
      document.getElementById('videoCueBox').classList.remove(removeClass);
      localStorage.setItem('MP_FE_SUBTUTLE_FONT', this.mx_cueFontSize);
      let addClass = `video-cue-class-${this.mx_cueFontSize}`;
      document.getElementById('videoCueBox').classList.add(addClass);
    },

  },
};
